﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;

namespace RJ.Objects.GameEngine
{
    public abstract class GameState : GameObject, IDisposable
    {
        public const int GAME_WIDTH = 1200;
        public const int GAME_HEIGHT = 700;

        protected GameView current;
        protected Queue<MouseEventArgs> mouseEvents;
        public Size clientSize;
        public GameSettings settings;
        public Size GameCenter;

        public GameState(Size clientSize)
        {
            this.clientSize = clientSize;
            GameCenter = new Size(clientSize.Width / 2, clientSize.Height / 2);
            mouseEvents = new Queue<MouseEventArgs>();
        }

        public abstract void Initialize();

        public override void Draw(Graphics g)
        {
            current.Draw(g);
        }

        public override void Update(double gameTime, double elapsedTime)
        {
            current.Update(gameTime, elapsedTime);
        }

        public virtual MouseEventArgs GetMouseEvent()
        {
            if (mouseEvents.Count > 0)
                return mouseEvents.Dequeue();
            else
                return null;
        }

        public abstract void KeyboardKeyPressed(Keys key);

        public virtual void MouseMove(object sender, MouseEventArgs e)
        {
            mouseEvents.Enqueue(e);
        }

        public virtual void MouseClick(object sender, MouseEventArgs e)
        {
            mouseEvents.Enqueue(e);
        }

        public virtual void Pause()
        {
            current.Pause();
        }

        public virtual void Dispose()
        {
            
        }
    }
}
